package com.hjm.project.ShopOrderBreak.ShopOrderBreak.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.ShopOrderBreak.ShopOrderBreak.domain.ShopOrderBreak;
import com.hjm.project.ShopOrderBreak.ShopOrderBreak.service.IShopOrderBreakService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 物流订单分发Controller
 * 
 * @author ShopOrderBreak
 * @date 2020-11-30
 */
@Controller
@RequestMapping("/ShopOrderBreak/ShopOrderBreak")
public class ShopOrderBreakController extends BaseController
{
    private String prefix = "ShopOrderBreak/ShopOrderBreak";

    @Autowired
    private IShopOrderBreakService shopOrderBreakService;

    @RequiresPermissions("ShopOrderBreak:ShopOrderBreak:view")
    @GetMapping()
    public String ShopOrderBreak()
    {
        return prefix + "/ShopOrderBreak";
    }

    /**
     * 查询物流订单分发列表
     */
    @RequiresPermissions("ShopOrderBreak:ShopOrderBreak:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ShopOrderBreak shopOrderBreak)
    {
        startPage();
        List<ShopOrderBreak> list = shopOrderBreakService.selectShopOrderBreakList(shopOrderBreak);
        return getDataTable(list);
    }

    /**
     * 导出物流订单分发列表
     */
    @RequiresPermissions("ShopOrderBreak:ShopOrderBreak:export")
    @Log(title = "物流订单分发", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ShopOrderBreak shopOrderBreak)
    {
        List<ShopOrderBreak> list = shopOrderBreakService.selectShopOrderBreakList(shopOrderBreak);
        ExcelUtil<ShopOrderBreak> util = new ExcelUtil<ShopOrderBreak>(ShopOrderBreak.class);
        return util.exportExcel(list, "ShopOrderBreak");
    }

    /**
     * 新增物流订单分发
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存物流订单分发
     */
    @RequiresPermissions("ShopOrderBreak:ShopOrderBreak:add")
    @Log(title = "物流订单分发", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ShopOrderBreak shopOrderBreak)
    {
        return toAjax(shopOrderBreakService.insertShopOrderBreak(shopOrderBreak));
    }

    /**
     * 修改物流订单分发
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ShopOrderBreak shopOrderBreak = shopOrderBreakService.selectShopOrderBreakById(id);
        mmap.put("shopOrderBreak", shopOrderBreak);
        return prefix + "/edit";
    }

    /**
     * 修改保存物流订单分发
     */
    @RequiresPermissions("ShopOrderBreak:ShopOrderBreak:edit")
    @Log(title = "物流订单分发", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ShopOrderBreak shopOrderBreak)
    {
        return toAjax(shopOrderBreakService.updateShopOrderBreak(shopOrderBreak));
    }

    /**
     * 删除物流订单分发
     */
    @RequiresPermissions("ShopOrderBreak:ShopOrderBreak:remove")
    @Log(title = "物流订单分发", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(shopOrderBreakService.deleteShopOrderBreakByIds(ids));
    }
}
